package com.glb.gilibuy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description: 访问http://localhost:8080/swagger-ui.html#/
 * @Author: Yingtian qian
 * @Date: 2021/7/31 14:24
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.glb.gilibuy.web")
@EnableSwagger2
public class Swagger2 {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.glb.gilibuy"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("给力百ACG周边/票务商城")
                .description("这是gilibuy ACG周边/票务商城的swagger2页面")
                .termsOfServiceUrl("http://www.baidu.com/")
                .contact("Qian")
                .version("1.0")
                .build();
    }
}
